#pragma once

#include <iostream>
#include <cstring>

std::string opers = "+-*/%";

enum
{
    Divzero=1,
    Modzero,
    Unknow
};

class Task
{
public:
    Task(int x, int y,char op) : _data1(x), _data2(y), _oper(op), _result(0), _exitcode(0)
    {
    }

    void Run()
    {
        switch(_oper)
        {
            case '+':
                _result=_data1+_data2;
                break;
            case '-':
                _result=_data1-_data2;
                break;
            case '*':
                _result=_data1*_data2;
                break;
            case '/':
                if(_data2==0)
                    _exitcode=Divzero;
                else
                    _result=_data1/_data2;
                break;
            case '%':
                if(_data2==0)
                    _exitcode=Modzero;
                else
                    _result=_data1%_data2;
                break;
            default:
                _exitcode=Unknow;
                break;
        }
    }
    void operator()()
    {
        Run();
    }

    std::string GetResult()
    {
        std::string r=std::to_string(_data1);
        r+=_oper;
        r+=std::to_string(_data2);
        r+="=";
        r+=std::to_string(_result);
        r+="[code: ";
        r+=std::to_string(_exitcode);
        r+="]";
        return r;
    }

    std::string GetTask()
    {
        std::string t=std::to_string(_data1);
        t+=_oper;
        t+=std::to_string(_data2);
        t+="= ?";
        return t;
    }

    ~Task()
    {}
private:
    int _data1;
    int _data2;
    char _oper;
    int _result;
    int _exitcode;
};